import { webxGlobalStore } from "../store/webxGlobal.store";

class Mapping {

  // 前缀
  prefix: string;

  constructor(options?:UseMappingOptions) {
    this.prefix = (options?.prefix || "webx") + ":";
  }

  // sessionStorage的keys
  get SessionKeys() {
    return {
      /**
       * webxRouteTabs路由页签组件存储
       * 值为object
       * object.dataSource: 当前打开的页签
       * */
      routeTabs: this.prefix + "webx-route-tabs"
    }
  }

  // localStorage的keys
  get LocalKeys() {
    return {
      /**
       * webxDict字典组件存储
       * 值为object
       * object.dataSource: 字典数据源
       * object.updateDate: 字典更新时间
       * */
      dict: this.prefix + "webx-dict",
    }
  }
}

export default function useMapping() {
  return new Mapping({
    prefix:webxGlobalStore().prefix
  });
}



export declare interface UseMappingOptions {
  // 公共前缀
  prefix?: string;
}